<?php
function curlPost($url, $post_data = 0,$is_post = 0, $header1 = array('Content-Type: application/json') )
{
    $ch = curl_init();
    if ($ch === false) {
        die('cURL初始化失败');
    }

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, $is_post);
    if($is_post == 1){
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $output = curl_exec($ch);

    if ($output === false) {
        echo 'cURL错误：' . curl_error($ch);
    }

    curl_close($ch);

    return $output;
}
function curlGet($url)
{
    $headers = [
        "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
        "accept-encoding: gzip, deflate, br, zstd",
        "accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "cache-control: max-age=0",
        "connection: keep-alive",
        "cookie: HMF_CI=1349e1353ed1cc839c5ffb50d1c6567b6f173e41c20212c39e1a6d3cfdec153541758c4fa030a41d07eee886436a3fb51632b336f185ac782ce6df91f8bfc4128d; 21_vq=2",
        "host: www.cwl.gov.cn",
        "sec-ch-ua: \"Microsoft Edge\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
        "sec-ch-ua-mobile: ?0",
        "sec-ch-ua-platform: \"Windows\"",
        "sec-fetch-dest: document",
        "sec-fetch-mode: navigate",
        "sec-fetch-site: none",
        "sec-fetch-user: ?1",
        "upgrade-insecure-requests: 1",
        "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('text/json;charset=UTF-8'));
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    $output = curl_exec($ch);
    if ($output === false) {
        echo 'cURL Error: ' . curl_error($ch);
    }
    curl_close($ch);
    return $output;
}
